home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / FORTRAN / SPHERE.F < prev   
Encoding:
Text File  |  1998-08-12  |  1.5 KB  |  55 lines

  1.  
  2. C  Copyright (c) Mark J. Kilgard, 1994.
  3.  
  4. C  This program is freely distributable without licensing fees
  5. C  and is provided without guarantee or warrantee expressed or
  6. C  implied.  This program is -not- in the public domain.
  7.  
  8. C  GLUT Fortran program to draw red light sphere.
  9.  
  10.     subroutine display
  11. #include "GL/fgl.h"
  12.     call fglclear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
  13.     call fglcalllist(1)
  14.     call glutswapbuffers
  15.     end
  16.  
  17.     subroutine gfxinit
  18. #include "GL/fgl.h"
  19.     real diffuse(4),pos(4)
  20.     data diffuse /1.0, 0.0, 0.0, 1.0/
  21.     data pos /1.0, 1.0, 1.0, 0.0/
  22.     call fglnewlist(1, GL_COMPILE)
  23.     call glutsolidsphere(dble(1.0), 20, 20)
  24.     call fglendlist
  25.     call fgllightfv(GL_LIGHT0, GL_DIFFUSE, diffuse)
  26.     call fgllightfv(GL_LIGHT0, GL_POSITION, pos)
  27.     call fglenable(GL_LIGHTING)
  28.     call fglenable(GL_LIGHT0)
  29.     call fglenable(GL_DEPTH_TEST)
  30.     call fglmatrixmode(GL_PROJECTION)
  31.     call fgluperspective(dble(40.0), dble(1.0),
  32.      2                       dble(1.0), dble(10.0))
  33.     call fglmatrixmode(GL_MODELVIEW)
  34.     call fglulookat(dble(0.0), dble(0.0), dble(5.0),
  35.      2                  dble(0.0), dble(0.0), dble(0.0),
  36.      3                  dble(0.0), dble(1.0), dble(1.0))
  37.     call fgltranslatef(0.0, 0.0, -1.0)
  38.     end
  39.  
  40.     program main
  41. #include "GL/fglut.h"
  42.     external display
  43.     external reshape
  44.     external submenu
  45.     external mainmenu
  46.     integer win
  47.     call glutinit
  48.     call glutinitdisplaymode(GLUT_DOUBLE+GLUT_RGB+GLUT_DEPTH)
  49.     win =  glutcreatewindow('Fortran GLUT sphere')
  50.     call gfxinit
  51.     call glutdisplayfunc(display)
  52.     call glutmainloop
  53.     end
  54.  
  55.